﻿using System;

namespace TypeBuilderFx.Core.Emitters
{
	/// <summary>Options for <see cref="ImmutablePropertyHolderEmitter"/>.</summary>
	public class ImmutablePropertyHolderOptions : SupportBaseClassTypeEmitterOptions
    {
		/// <summary>Sets default values.</summary>
		public ImmutablePropertyHolderOptions()
		{
			ReferenceTypeValidationLevel = ReferenceTypeValidationLevel.NoNullAndEmptyString;
		}

		/// <summary>Returns the validation level for all reference types.</summary>
		/// <remarks>This level can be overriden by applying <see cref="ReferenceTypeValidationAttribute"/> on properties.</remarks>
		public ReferenceTypeValidationLevel ReferenceTypeValidationLevel { get; set; }

        #region object Methods
        /// <summary>Must be overriden by derived classes in order to be able to use as a key in an dictionary.</summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
			return base.GetHashCode() ^ ReferenceTypeValidationLevel.GetHashCode();
        }

        /// <summary>Must be overriden by derived classes in order to be able to use as a key in an dictionary.</summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
			ImmutablePropertyHolderOptions options = obj as ImmutablePropertyHolderOptions;

			return base.Equals(obj) && options != null && options.ReferenceTypeValidationLevel == ReferenceTypeValidationLevel;
        }
        #endregion
    }
}